﻿<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>添加新管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../style/adminStyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>

<script type="text/javascript">

function updatepwd() {
	var jurisdiction=$("input[name='re']:checked").val();
	var details=$("input[name='det']:checked").val();
	var rname=$("#rname").val();
	var phone=$("#phone").val();
	var email=$("#email").val();
	//验证两次输入密码是否相同
	
		var oldPwd = $("#password1").val();
		var newPwd = $("#password2").val();
		if(oldPwd==newPwd&&oldPwd!=null&newPwd!=null){

			  if(rname ==""||rname==null){
	              //设置为默认值
	              alert("名称不能为空");
	             
	              return false;
	  
	        }
			  if(phone ==""||phone==null){
	              //设置为默认值
	              alert("手机不能为空");
	             
	              return false;
	        }
			  if(email ==""||email==null){
	              //设置为默认值
	              alert("邮箱不能为空");
	             
	              return false;
	        } 
			 $.ajax({
					"url":"${pageContext.request.contextPath}/Administrators/add_admin.do",
					"data":{'jurisdiction':jurisdiction,'details':details,
						'rname':rname,'rpassword':newPwd,'phone':phone,'email':email},
					"type":"POST",
					"dataType":"json",
					"success":function(obj){

						if(obj.state==1){
							 alert("添加成功");
							 location="${pageContext.request.contextPath}/Administrators/admin_list.do";
							
						}else{
							alert("管理已存在");
						}
				
					}});
				
			return true;
				
		}else{
			 alert("密码设置不一致");
			 return false;
		}		
		
}

</script>

</head>

<body>
 <div class="wrap">
  <div class="page-title">
    <span class="modular fl"><i class="user"></i><em>成员注册</em></span>
  </div>
  <table class="noborder">
   
  <tr>
    <td style="text-align:right;">账号/姓名：</td>
    <td><input type="text" class="textBox length-middle" name="rname" id="rname"/><span style="color:red">*若添加第三方大师管理员,需账号/姓名与已有大师名称必须相同</span></td>
   </tr>
   <tr>
    <td style="text-align:right;">手机号码：</td>
    <td><input type="text" class="textBox length-middle" name="phone" id="phone"/><span style="color:red">*必填</span></td>
   </tr>
   <tr>
    <td style="text-align:right;">电子邮箱：</td>
    <td><input type="text" class="textBox length-middle" name="email" id="email"/><span style="color:red">*必填</span></td>
   </tr>
   <tr>
    <td style="text-align:right;">登陆密码：</td>
    <td><input type="password" class="textBox length-middle" name="password1" id="password1"/><span style="color:red">*必填</span></td>
   </tr>
   <tr>
    <td style="text-align:right;">再次确认密码：</td>
    <td><input type="password" class="textBox length-middle" name="password2" id="password2"/><span style="color:red">*必填</span></td>
   </tr>
     <tr>
    <td style="text-align:right;">权限：</td>
    <td><input name="re" type="radio" checked="checked" value="1"/>初级管理员&nbsp;&nbsp;&nbsp;<input name="re" type="radio" value="2"/>中级管理员</td>
   </tr>
    <tr>
    <td style="text-align:right;">职责：</td>
    <td><input name="det" type="radio" checked="checked" value="1"/>运营人员&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="det" type="radio" value="2"/>合作方</td>
   </tr>
   <tr>
    <td style="text-align:right;"></td>
    <td><input type="submit" class="tdBtn" value="保存" onclick="updatepwd()"/></td>
   </tr>
 
  </table>
 </div>
</body>

</html>